package com.ssyc.gsk_master.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ssyc.common.glide.ImageUtil;
import com.ssyc.gsk_master.R;
import com.ssyc.gsk_master.bean.EventInfo;

import java.util.List;

/**
 * 获取列表适配器
 * Created by Administrator on 2018/1/19 0019.
 */

public class EventAdapter extends BaseQuickAdapter<EventInfo.ListBean, BaseViewHolder> {
    private Context context;

    public EventAdapter(Context context, int layoutResId, @Nullable List<EventInfo.ListBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, EventInfo.ListBean item) {
        //活动图片
        ImageView ivHead = helper.getView(R.id.lv_head);
        ImageUtil.displayImage(context, ivHead, item.getPicture1(), R.drawable.base_event_def);

        //活动名称
        TextView tvName = helper.getView(R.id.tv_name);
        tvName.setText(item.getTag());

        //活动对象
        TextView tvClass = helper.getView(R.id.tv_class);
        tvClass.setText("班级:" + item.getTarget());

        //活动时间
        TextView tvTime = helper.getView(R.id.tv_time);
        tvTime.setText("时间:" + item.getBegintime() + "~" + item.getEndtime());

        //活动地点
        TextView tvAddress = helper.getView(R.id.tv_address);
        tvAddress.setText("地点:" + item.getAddress());

        //活动简介
        TextView tvContent = helper.getView(R.id.tv_content);
        tvContent.setText("活动简介:" + item.getContent());

        //活动状态
        TextView tvState = helper.getView(R.id.tv_state);
        if ("1".equals(item.getStatus())) {
            //进行中
            tvState.setText("进行中");
            tvState.setBackgroundResource(R.drawable.master_tv_state_ing);

        } else if ("0".equals(item.getStatus())) {
            //报名中
            tvState.setText("报名中");
            tvState.setBackgroundResource(R.drawable.master_tv_state_no_start);

        } else if ("2".equals(item.getStatus())) {
            //已结束
            tvState.setText("已结束");
            tvState.setBackgroundResource(R.drawable.master_tv_state_over);
        }
    }
}
